class Tabbar extends React.Component {
    constructor(props) {
  super(props);
  this.state = {
    index:this.props.index
   };
    }


    // click(){
    //     this.props.click()
    // }
    
    componentWillReceiveProps(e){
      console.log(e.index,'e.index');
      
      this.setState({index:e.index})
      
    }
    click(i){
      let {index} = this.state;
      if(index!=i){
        window.location.href= './'+(i==0?'main':i==2?'friend':i==1?'zone':'mine')+'.html'
        this.setState({index:i})

      }
    }
componentDidMount() {
  
var that = this

}
     render() {
       let {index} = this.state
            return(
                <div    className="tabbar" >
                  
                  <div onClick={this.click.bind(this,0)} className={'item'+(index==0?' c':'')}>
                    <img src={'./src/tabbar_main'+(index==0?'_c':'')+'.png'} alt="" />
                    <p className="word">首页</p>
                    </div>
                     <div onClick={this.click.bind(this,1)} className={'item'+(index==1?' c':'')}>
                     <img src={'./src/tabbar_friend'+(index==1?'_c':'')+'.png'} alt="" />
                    <p className="word">友圈</p>
                    </div>
                     <div  onClick={this.click.bind(this,2)}className={'item'+(index==2?' c':'')}>
                    <img src={'./src/tabbar_quan'+(index==2?'_c':'')+'.png'} alt="" />
                    <p className="word">友搭</p>
                    </div>
                     <div onClick={this.click.bind(this,3)} className={'item'+(index==3?' c':'')}>
                    <img src={'./src/tabbar_mine'+(index==3?'_c':'')+'.png'} alt="" />
                    <p className="word">我的</p>
                    </div>
                </div>
            )
        }
    }